package in.ac.dei.edrp.cms.daoimpl.settings;

import java.util.ArrayList;
import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import in.ac.dei.edrp.cms.dao.settings.SettingService;
import in.ac.dei.edrp.cms.domain.login.Login;
import in.ac.dei.edrp.cms.domain.studentmaster.StudentMasterInfoBean;

public class SettingServiceImpl extends SqlMapClientDaoSupport implements
		SettingService {

	@SuppressWarnings("unchecked")
	public List<StudentMasterInfoBean> getUserAddress(String studentId) {
		List<StudentMasterInfoBean> addressData = new ArrayList<StudentMasterInfoBean>();
		try {
			addressData = getSqlMapClientTemplate().queryForList(
					"addStduentInMaster.getStudentAddressDetail", studentId);
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
		return addressData;
	}

	public Boolean changeUserAddress(
			List<StudentMasterInfoBean> studentMasterInfoBean) {
		Boolean bool = false;
		try {
			for (int i = 0; i < studentMasterInfoBean.size(); i++) {
				getSqlMapClientTemplate().update(
						"addStduentInMaster.updateaddressmaster",
						studentMasterInfoBean.get(i));
			}
			bool = true;
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
		return bool;
	}

	public Boolean changeUserPassword(Login login) {
		Boolean bool = false;
		try {
			getSqlMapClientTemplate().update("login.changePassword", login);
			bool = true;
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
		return bool;
	}
}